/* Copyright (c) 2025 Beijing Semidrive Technology Corporation
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * @file  rtl820f.h
 * @brief Semidrive. AUTOSAR 4.3.1 MCAL EthTrcv plugins.
 */

#ifndef RTL820F_H
#define RTL820F_H

#ifdef __cplusplus
extern "C" {
#endif

#include "EthTrcv.h"

#define     udelay(x)     Mcal_udelay(x)

#define SD_MII_BMCR            0x00
#define SD_MII_BMSR            0x01
#define SD_MII_PHYSID1         0x02
#define SD_MII_PHYSID2         0x03
#define SD_MII_ADVERTISE       0x04
#define SD_MII_LPA             0x05
#define SD_MII_EXPANSION       0x06

#define SD_MII_PHYSTS          0x10
#define SD_MII_PHYCR           0x19

/* Basic mode control register. */
#define SD_BMCR_RESV           0x003f
#define SD_BMCR_SPEED1000      0x0040
#define SD_BMCR_CTST           0x0080
#define SD_BMCR_FULLDPLX       0x0100
#define SD_BMCR_ANRESTART      0x0200
#define SD_BMCR_ISOLATE        0x0400
#define SD_BMCR_PDOWN          0x0800
#define SD_BMCR_ANENABLE       0x1000
#define SD_BMCR_SPEED100       0x2000
#define SD_BMCR_LOOPBACK       0x4000
#define SD_BMCR_RESET          0x8000
#define SD_BMCR_SPEED10        0x0000


#if !defined(GENMASK)
#define GENMASK(h, l) \
    (((~0UL) - (1UL << (l)) + 1) & (~0UL >> (32 - 1 - (h))))
#endif

#define SD_PHYID_OUI       GENMASK(31,10)
#define SD_PHYID_VENDOR    GENMASK(9,4)
#define SD_PHYID_VERSION   GENMASK(3,0)


#if ETHTRCV_RTL820F_SUPPORTED == STD_ON
extern const EthTrcv_Ops_Type rtl820f_ops;
#endif

#ifdef __cplusplus
}
#endif

#endif
